package com.sunny.a1;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<>();

        int n = scanner.nextInt();
        int[] arr = new int[n];
        for(int i=0;i<n;i++){
            arr[i] = scanner.nextInt();
            list.add(arr[i]);
        }

        if(judgeDc(list) || judgeDb(list))
            System.out.println(1);
        else
            System.out.println(0);

    }


    public static boolean judgeDc(ArrayList<Integer> list){
        boolean flag = true;
        int width = list.get(1)-list.get(0);
        for(int i=2;i<list.size();i++){
            int tmpWidth = list.get(i) - list.get(i-1);
            if(tmpWidth != width){
                flag = false;
                break;
            }
        }
        return flag;
    }

    public static boolean judgeDb(ArrayList<Integer> list){
        boolean flag = true;
        int times;
        if(0 == list.get(1)%list.get(0))
            times = list.get(1)/list.get(0);
        else
            return false;
        for(int i=2;i<list.size();i++){
            int tmpTimes;
            if(0 == list.get(i)%list.get(i-1))
                tmpTimes = list.get(i) - list.get(i-1);
            else
                return false;
            if(tmpTimes != times){
                flag = false;
                break;
            }
        }
        return flag;
    }


}
